/**
 * @Author yinyunqi
 * @date 2018年1月24日
 * @Content 
 */
package com.yongqi.controller.console;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.yongqi.model.Family;
import com.yongqi.model.console.Bill;
import com.yongqi.pub.PrincipalFormat;
import com.yongqi.service.MemberService;
import com.yongqi.service.console.BillService;

@Controller
@RequestMapping("/map")
public class MapController {
    @Autowired
    MemberService memberService;
    @Autowired
    BillService billService;
    @RequestMapping("/index")
    public String mapIndex() {
	return "map/map";
    }
    @RequestMapping("/index2")
    public String mapIndex2() {
	return "map/map2";
    }
    @RequestMapping("/mapIndex")
    public String mapIndex3(Model model) {
	String familyAccount = ((Family) SecurityUtils.getSubject().getPrincipal()).getFamilyaccount();
	List<String> memberNametList = memberService.selectMemberByFamily(familyAccount);
	model.addAttribute("nameList", memberNametList);
	return "map/MapIndex";
    }
//    @RequestMapping("/translate")
//    @ResponseBody
//    public String translate(HttpServletRequest request) {
//    	String address = null;
//		//前台获取经纬度并工具类解析
//		String lng = request.getParameter("lng");//经度
//		String lat = request.getParameter("lat");//纬度
//		System.out.println(lat+","+lng);
//		address = BaiduMapTranslate.addressTranslate(lat, lng);
//		address = address.replaceAll("renderReverse","");
//		address = address.replaceAll("&","");
//		address = address.replaceAll("\\(|\\)","");
//		System.out.println(address);
//		JSONObject addr = JSONObject.fromObject(address);
//		com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
//		object.put("addr", address);
//		return object.toJSONString();
//    } 
    @RequestMapping("/paypath")
    public String paypath() {
	return "pay/paypath";
    }
    @ResponseBody
    @RequestMapping("/paydata")
    public String paydata() {
	Map<String, String> map = new HashMap<String, String>();
	map.put("familyAccount", PrincipalFormat.currentFA());
	map.put("billType", "pay");
	List<Bill> mapBillList = billService.payPathMap(map);
	JSONObject object = new JSONObject();
	object.put("data", mapBillList);
	return object.toJSONString();
    }
}

